#include <iostream>
#include <string>
#include <sstream>

using namespace std;

bool isPrime(int n) {
  if (n <= 1) {
    return false;
  }
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  string input;
  getline(cin, input);

  stringstream ss(input);
  string word1, word2, word3;
  ss >> word1 >> word2 >> word3;

  int num = 0;

  if (word1 == "zero") {
    num += 0;
  } else if (word1 == "one") {
    num += 1;
  } else if (word1 == "two") {
    num += 2;
  } else if (word1 == "three") {
    num += 3;
  } else if (word1 == "four") {
    num += 4;
  } else if (word1 == "five") {
    num += 5;
  } else if (word1 == "six") {
    num += 6;
  } else if (word1 == "seven") {
    num += 7;
  } else if (word1 == "eight") {
    num += 8;
  } else if (word1 == "nine") {
    num += 9;
  } else {
    cout << "Wrong input" << endl;
    return 1;
  }

  num *= 10;

  if (word2 == "zero") {
    num += 0;
  } else if (word2 == "one") {
    num += 1;
  } else if (word2 == "two") {
    num += 2;
  } else if (word2 == "three") {
    num += 3;
  } else if (word2 == "four") {
    num += 4;
  } else if (word2 == "five") {
    num += 5;
  } else if (word2 == "six") {
    num += 6;
  } else if (word2 == "seven") {
    num += 7;
  } else if (word2 == "eight") {
    num += 8;
  } else if (word2 == "nine") {
    num += 9;
  } else {
    cout << "Wrong input" << endl;
    return 1;
  }

  num *= 10;

  if (word3 == "zero") {
    num += 0;
  } else if (word3 == "one") {
    num += 1;
  } else if (word3 == "two") {
    num += 2;
  } else if (word3 == "three") {
    num += 3;
  } else if (word3 == "four") {
    num += 4;
  } else if (word3 == "five") {
    num += 5;
  } else if (word3 == "six") {
    num += 6;
  } else if (word3 == "seven") {
    num += 7;
  } else if (word3 == "eight") {
    num += 8;
  } else if (word3 == "nine") {
    num += 9;
  } else {
    cout << "Wrong input" << endl;
    return 1;
  }

  if (num < 100 || num > 999) {
    cout << "Wrong input" << endl;
    return 1;
  }

  int closestPrime = num;
  bool found = false;

  while (!found) {
    if (isPrime(closestPrime)) {
      found = true;
    } else {
      closestPrime++;
    }
  }

  cout << closestPrime << endl;

  return 0;
}